#define _CRT_SECURE_NO_WARNINGS



#include<iostream>w
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i <= s.size() - k; i++)
    {
        for (int j = i + 1; j - i + 1 <= k; j++)
        {
            sum += abs(s[j] - s[j - 1]);
        }
    }
    cout << sum;
    return 0;
}

